<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			/**
			 * Definition for a binary tree node.
			 * function TreeNode(val, left, right) {
			 *     this.val = (val===undefined ? 0 : val)
			 *     this.left = (left===undefined ? null : left)
			 *     this.right = (right===undefined ? null : right)
			 * }
			 */
			/**
			 * @param {TreeNode} root
			 * @return {number[]}
			 */
			let r = new TreeNode(1,new TreeNode(2,null,null),new TreeNode(3,null,null));
			function TreeNode(val, left, right) {
			    this.val = (val===undefined ? 0 : val)
			    this.left = (left===undefined ? null : left)
			    this.right = (right===undefined ? null : right)
			}
			var postorderTraversal = function(root) {
				let res = [];
				var postorder = (root) => {
					if (!root) {
						return;
					}
					postorder(root.left);
					postorder(root.right);
					res.push(root.val);
				}
				postorder(root);
				return res;
			};
			console.log(postorderTraversal(r));
		</script>
	</body>
</html>
